-module(rtps_sup).

%%% @doc This is the rtps application's supervisor. It starts a
%%% registry for the domains, the supervisor which will later contain
%%% the domains and the applications main module and controlling
%%% process.

-behaviour(supervisor).

%% API
-export([start_link/0]).

%% Supervisor callbacks
-export([init/1]).

-define(SERVER, ?MODULE).

%%====================================================================
%% API functions
%%====================================================================

start_link() ->
    supervisor:start_link({local, ?SERVER}, ?MODULE, []).

%%====================================================================
%% Supervisor callbacks
%%====================================================================

init([]) ->
    {ok, {#{strategy => one_for_all},
	  [#{id => registry,
	     start => {rtps_reg, start_link, []},
	     restart => permanent,
	     type => worker},
	   #{id => domains,
	     start => {rtps_ofo_sup, start_link, []},
	     restart => permanent,
	     type => supervisor},
	   #{id => rtps,
	     start => {rtps, start_link, [self()]},
	     restart => permanent,
	     type => worker}
	  ]}}.

%%====================================================================
%% Internal functions
%%====================================================================
